home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Games / MAME / src / vidhrdw / kchamp.c < prev    next >
C/C++ Source or Header  |  1998-09-23  |  6KB  |  174 lines

  1. /***************************************************************************
  2.  
  3.   vidhrdw.c
  4.  
  5.   Functions to emulate the video hardware of the machine.
  6.  
  7. ***************************************************************************/
  8.  
  9. #include "driver.h"
  10. #include "vidhrdw/generic.h"
  11.  
  12. /* prototypes */
  13. void kchamp_vs_drawsprites( struct osd_bitmap *bitmap );
  14. void kchamp_1p_drawsprites( struct osd_bitmap *bitmap );
  15.  
  16.  
  17.  
  18. typedef void (*kchamp_drawspritesproc)( struct osd_bitmap * );
  19.  
  20. static kchamp_drawspritesproc kchamp_drawsprites;
  21.  
  22.  
  23. /***************************************************************************
  24.   Video hardware start.
  25. ***************************************************************************/
  26.  
  27. int kchampvs_vh_start(void) {
  28.  
  29.     kchamp_drawsprites = kchamp_vs_drawsprites;
  30.  
  31.     return generic_vh_start();
  32. }
  33.  
  34. int kchamp1p_vh_start(void) {
  35.  
  36.     kchamp_drawsprites = kchamp_1p_drawsprites;
  37.  
  38.     return generic_vh_start();
  39. }
  40.  
  41. /***************************************************************************
  42.   Convert color prom.
  43. ***************************************************************************/
  44. void kchamp_vh_convert_color_prom(unsigned char *palette, unsigned short *colortable,const unsigned char *color_prom)
  45. {
  46.         int i, red, green, blue;
  47.         #define TOTAL_COLORS(gfxn) (Machine->gfx[gfxn]->total_colors * Machine->gfx[gfxn]->color_granularity)
  48.         #define COLOR(gfxn,offs) (colortable[Machine->drv->gfxdecodeinfo[gfxn].color_codes_start + offs])
  49.  
  50.  
  51.     for (i = 0;i < Machine->drv->total_colors;i++)
  52.     {
  53.                 red = color_prom[i];
  54.                 green = color_prom[Machine->drv->total_colors+i];
  55.                 blue = color_prom[2*Machine->drv->total_colors+i];
  56.  
  57.  
  58.                 *(palette++) = red*0x11;
  59.                 *(palette++) = green*0x11;
  60.                 *(palette++) = blue*0x11;
  61.  
  62.  
  63.                 *(colortable++) = i;
  64.     }
  65.  
  66. }
  67.  
  68. void kchamp_vs_drawsprites( struct osd_bitmap *bitmap ) {
  69.  
  70.     int offs;
  71.             /*
  72.                 Sprites
  73.                 -------
  74.                 Offset          Encoding
  75.                   0             YYYYYYYY
  76.                   1             TTTTTTTT
  77.                   2             FGGTCCCC
  78.                   3             XXXXXXXX
  79.         */
  80.  
  81.         for (offs = 0 ;offs < 0x100;offs+=4)
  82.     {
  83.                 int numtile = spriteram[offs+1] + ( ( spriteram[offs+2] & 0x10 ) << 4 );
  84.                 int flipx = ( spriteram[offs+2] & 0x80 );
  85.                 int sx, sy;
  86.                 int gfx = 1 + ( ( spriteram[offs+2] & 0x60 ) >> 5 );
  87.                 int color = ( spriteram[offs+2] & 0x0f );
  88.  
  89.                 sx = spriteram[offs+3];
  90.                 sy = 240 - spriteram[offs];
  91.  
  92.                 drawgfx(bitmap,Machine->gfx[gfx],
  93.                                 numtile,
  94.                                 color,
  95.                                 0, flipx,
  96.                                 sx,sy,
  97.                                 &Machine->drv->visible_area,TRANSPARENCY_PEN,0);
  98.     }
  99. }
  100.  
  101. void kchamp_1p_drawsprites( struct osd_bitmap *bitmap ) {
  102.  
  103.     int offs;
  104.             /*
  105.                 Sprites
  106.                 -------
  107.                 Offset          Encoding
  108.                   0             YYYYYYYY
  109.                   1             TTTTTTTT
  110.                   2             FGGTCCCC
  111.                   3             XXXXXXXX
  112.         */
  113.  
  114.         for (offs = 0 ;offs < 0x100;offs+=4)
  115.     {
  116.                 int numtile = spriteram[offs+1] + ( ( spriteram[offs+2] & 0x10 ) << 4 );
  117.                 int flipx = ( spriteram[offs+2] & 0x80 );
  118.                 int sx, sy;
  119.                 int gfx = 1 + ( ( spriteram[offs+2] & 0x60 ) >> 5 );
  120.                 int color = ( spriteram[offs+2] & 0x0f );
  121.  
  122.                 sx = spriteram[offs+3] - 8;
  123.                 sy = 247 - spriteram[offs];
  124.  
  125.                 drawgfx(bitmap,Machine->gfx[gfx],
  126.                                 numtile,
  127.                                 color,
  128.                                 0, flipx,
  129.                                 sx,sy,
  130.                                 &Machine->drv->visible_area,TRANSPARENCY_PEN,0);
  131.     }
  132. }
  133.  
  134. /***************************************************************************
  135.  
  136.   Draw the game screen in the given osd_bitmap.
  137.   Do NOT call osd_update_display() from this function, it will be called by
  138.   the main emulation engine.
  139.  
  140. ***************************************************************************/
  141.  
  142. void kchamp_vh_screenrefresh(struct osd_bitmap *bitmap,int full_refresh)
  143. {
  144.         int offs;
  145.  
  146.     /* for every character in the Video RAM, check if it has been modified */
  147.     /* since last time and update it accordingly. */
  148.         for ( offs = videoram_size - 1; offs >= 0; offs-- ) {
  149.                 if ( dirtybuffer[offs] ) {
  150.             int sx,sy,code;
  151.  
  152.             dirtybuffer[offs] = 0;
  153.  
  154.                         sx = (offs % 32);
  155.             sy = (offs / 32);
  156.  
  157.                         code = videoram[offs] + ( ( colorram[offs] & 7 ) << 8 );
  158.  
  159.                         drawgfx(tmpbitmap,Machine->gfx[0],
  160.                                         code,
  161.                                         ( colorram[offs] >> 3 ) & 0x1f,
  162.                                         0, /* flip x */
  163.                                         0, /* flip y */
  164.                     sx*8,sy*8,
  165.                     &Machine->drv->visible_area,TRANSPARENCY_NONE,0);
  166.         }
  167.     }
  168.  
  169.     /* copy the character mapped graphics */
  170.     copybitmap(bitmap,tmpbitmap,0,0,0,0,&Machine->drv->visible_area,TRANSPARENCY_NONE,0);
  171.  
  172.     (*kchamp_drawsprites)( bitmap);
  173. }
  174.